package designPattern.factory.simpleFactory.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class OrderPizza {

    //构造器
    public OrderPizza(){
        Pizza pizza = null;
        String orderType;//订购披萨类型
        do {
            orderType = getType();
            if(orderType.equals("greek")){
                pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        }else if(orderType.equals("chess")){
            pizza = new ChessPizza();
            pizza.setName("奶酪披萨");
        }else {
            break;
        }
            //输出pizza制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }while (true);
    }

    //写一个方法，输入获得披萨种类
    private String getType() {
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza种类：");
            String str = strin.readLine();
            return str;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
